package com.yangchuang.openpicture.service;

// 单独的Builder类
public class UserStatsUpdateBuilder {
    // 依赖的业务类实例（必须传入，用于调用更新方法）
    private final UserStatisticsService userStatisticsService;
    // 必传参数
    private final Long userId;
    // 可选参数（默认null）
    private Boolean liked;
    private Boolean favorited;
    private Boolean commented;
    private Boolean followed;
    private Boolean viewed;
    private Boolean downloaded;
    private Boolean like;
    private Boolean favorite;
    private Boolean comment;
    private Boolean follow;
    private Boolean download;
    private Boolean view;
    private Boolean publish;


    // 构造器：必须传入业务类实例和userId
    public UserStatsUpdateBuilder(UserStatisticsService userStatisticsService, Long userId) {
        this.userStatisticsService = userStatisticsService;
        this.userId = userId;
    }

    // 链式setter方法（与之前逻辑一致）
    public UserStatsUpdateBuilder setLiked(Boolean liked) {
        this.liked = liked;
        return this;
    }

    public UserStatsUpdateBuilder setFavorited(Boolean favorited) {
        this.favorited = favorited;
        return this;
    }

    public UserStatsUpdateBuilder setCommented(Boolean commented) {
        this.commented = commented;
        return this;
    }

    public UserStatsUpdateBuilder setFollowed(Boolean followed) {
        this.followed = followed;
        return this;
    }

    public UserStatsUpdateBuilder setViewed(Boolean viewed) {
        this.viewed = viewed;
        return this;
    }

    public UserStatsUpdateBuilder setDownloaded(Boolean downloaded) {
        this.downloaded = downloaded;
        return this;
    }

    public UserStatsUpdateBuilder setLike(Boolean like) {
        this.like = like;
        return this;
    }

    public UserStatsUpdateBuilder setFavorite(Boolean favorite) {
        this.favorite = favorite;
        return this;
    }

    public UserStatsUpdateBuilder setComment(Boolean comment) {
        this.comment = comment;
        return this;
    }

    public UserStatsUpdateBuilder setFollow(Boolean follow) {
        this.follow = follow;
        return this;
    }

    public UserStatsUpdateBuilder setDownload(Boolean download) {
        this.download = download;
        return this;
    }

    public UserStatsUpdateBuilder setView(Boolean view) {
        this.view = view;
        return this;
    }

    public UserStatsUpdateBuilder setPublish(Boolean publish) {
        this.publish = publish;
        return this;
    }

    // 执行更新：通过业务类实例调用实际方法
    public void execute() {
        userStatisticsService.UserStatsHashUpdate(
                userId,
                liked,
                favorited,
                commented,
                followed,
                viewed,
                downloaded,
                like,
                favorite,
                comment,
                follow,
                download,
                view,
                publish
        );
    }
}
